from tools.utils import do_rest
from tools.transcoder import chinese_url_transcoding


class ExportExcel():
    """导出用户名单的接口"""

    def __init__(self):
        self.url = 'https://xxxxxx/xx'

    def export_user_info(self, opName):
        """根据搜索的结果导出表格"""
        file_name = './用户信息.xlsx'
        chinese_url_transcoding(opName)
        data = {"1": 1, "opName": opName}

        re = do_rest(self.url, data, 'get1')
        with open(file_name, 'wb') as code:
            code.write(re.content)
